package com.island.model;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="action")
public class Action {

	private int actionID;//权限主键ID
	private int actionColumnID;//权限栏目ID
	private String actionName;//权限名称
	private String actionDescribe;//权限描述
	private String actionUrl;//权限地址
	
	private Set<Role> roles = new LinkedHashSet<Role>();//用户集合
	
	@Id @GeneratedValue
    @Column(name="actionid", unique=true, nullable=false)
	public int getActionID() {
		return actionID;
	}
	public void setActionID(int actionID) {
		this.actionID = actionID;
	}
	
	@Column(name="actionColumnID")
	public int getActionColumnID() {
		return actionColumnID;
	}
	public void setActionColumnID(int actionColumnID) {
		this.actionColumnID = actionColumnID;
	}
	
	@Column(name="actionName")
	public String getActionName() {
		return actionName;
	}
	public void setActionName(String actionName) {
		this.actionName = actionName;
	}
	
	@Column(name="actionDescribe")
	public String getActionDescribe() {
		return actionDescribe;
	}
	public void setActionDescribe(String actionDescribe) {
		this.actionDescribe = actionDescribe;
	}
	
	@Column(name="actionUrl")
	public String getActionUrl() {
		return actionUrl;
	}
	public void setActionUrl(String actionUrl) {
		this.actionUrl = actionUrl;
	}
	
	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE }, 
	fetch = FetchType.LAZY, mappedBy="actions")
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
}
